package main

import (
	"log"
	"net/http"
)

// 定义"/hello" 请求处理器函数
func helloHandler(writer http.ResponseWriter, request *http.Request) {
	writer.Write([]byte("你好，go web"))
}

// 定义"/world" 请求处理器函数
func worldHandler(writer http.ResponseWriter, request *http.Request) {
	writer.Write([]byte("go web wrold"))
}

func main() {
	// 为"/hello"路由绑定处理器函数
	http.HandleFunc("/hello", helloHandler)
	// 为"/world"路由绑定处理器函数
	http.HandleFunc("/world", worldHandler)
	// 启动服务并监听8090端口
	err := http.ListenAndServe("localhost:8090", nil)
	log.Fatal(err)
}
